package com.scrcu.cloud.wechat.home.endpoint.auth.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Util {
    public static String calculateSHA1(String input) {
        try {
            MessageDigest sha1Digest = MessageDigest.getInstance("SHA-1");
            byte[] hashedBytes = sha1Digest.digest(input.getBytes());
            StringBuilder sb = new StringBuilder();
            for (byte b : hashedBytes) {
                sb.append(String.format("%02x", b));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("SHA-1 not supported", e);
        }
    }
}
